package com.atguigu.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author Mr.Zheng
 * @Date 2023/6/14 19:39
 *
 * union合流 ： 被union的流中的数据类型必须一致
 *
 */
public class Flink09_UnionStream {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3, 4, 5);

        DataStreamSource<Integer> ds2 = env.fromElements(6, 7, 8, 9, 10);

        DataStreamSource<String> ds3 = env.fromElements("a", "b", "c", "d", "e");


        DataStream<Integer> unionStream = ds1.union(ds2);

        unionStream.print();

        env.execute();
    }
}
